package com.example.schedule.log;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.example.schedule.R;
import com.example.schedule.db.Log;

public class LogCreateActivity extends AppCompatActivity {

    private Button mLogSave;
    private Button mLogBack;
    private EditText mLogText;
    private String writeLog;
    Log mLog = new Log();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_log_create);

        initView();
        initEvent();
    }

    private void initEvent() {
        mLogBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        mLogSave.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                writeLog = mLogText.getText().toString().trim();
                if(!writeLog.isEmpty()){
                    mLog.setLogWrite(writeLog);
                    mLog.saveThrows();
                }
                finish();
            }
        });
    }

    private void initView() {
        mLogSave = findViewById(R.id.save);
        mLogText = (EditText)findViewById(R.id.edit_text);
        mLogBack = findViewById(R.id.back);
    }
}